/*
 * leds.h
 *
 *  Created on: Dec 7, 2008
 *      Author: campbelm
 */

#ifndef LEDS_H_
#define LEDS_H_

#include <avr/io.h>

#define Leds_init()     (DDRD |= 0xF0)
#define Leds_on()       (PORTD |= 0xF0)   // Orange
#define Leds_off()      (PORTD &= 0x0F)
#define Led0_on()       (PORTD |= 0x10)   // Red
#define Led1_on()       (PORTD |= 0x20)   // Green
#define Led2_on()       (PORTD |= 0x40)   // Green
#define Led3_on()       (PORTD |= 0x80)   // Red
#define Led0_off()      (PORTD &= 0xEF)
#define Led1_off()      (PORTD &= 0xDF)
#define Led2_off()      (PORTD &= 0xBF)
#define Led3_off()      (PORTD &= 0x7F)
#define Led0_toggle()   (PIND |= 0x10)
#define Led1_toggle()   (PIND |= 0x20)
#define Led2_toggle()   (PIND |= 0x40)
#define Led3_toggle()   (PIND |= 0x80)
#define Leds_set_val(c) (Leds_off(),PORTD |= (c<<4)&0xF0)
#define Leds_get_val()  (PORTD>>4)
#define Is_led0_on()    (PIND & 0x10 ? TRUE : FALSE)

#endif /* LEDS_H_ */
